//
//  Header.swift
//  globalcarbusiness
//
//  Created by dongzhenyu on 2017/7/3.
//  Copyright © 2017年 dongzhenyu. All rights reserved.
//

import UIKit

let WIDTH_SCALE = (UIScreen.main.bounds.width / 375)
let HEIGHT_SCALE = (UIScreen.main.bounds.height / 667)
let SCALE = (UIScreen.main.bounds.width/750)
let kScreenW = UIScreen.main.bounds.width
let kScreenH = UIScreen.main.bounds.height

/**
 颜色RGB值
 
 - parameter r: R值
 - parameter g: G值
 - parameter b: B值
 - parameter a: 透明度
 
 - returns:
 */
func RGBA(_ r:CGFloat,g:CGFloat,b:CGFloat,a:CGFloat) -> UIColor {
    return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a)
}

func StringSize(_ string: NSString, fontSize: CGFloat) -> CGSize {
    let option = NSStringDrawingOptions.usesLineFragmentOrigin
    return string.boundingRect(with: CGSize(width: kScreenW - 135 * WIDTH_SCALE, height: CGFloat(MAXFLOAT)), options: option, attributes: [NSFontAttributeName: UIFont.systemFont(ofSize: fontSize)], context: nil).size
}

//MARK: - 时间戳转为时间
func timeStampToString(_ timeStamp:String)->String {
    //        let timeStamp = "1474535047000" //2016-09-17 13:16:31 测试数据
    let string = NSString(string: timeStamp)
    
    let timeSta:TimeInterval = string.doubleValue/1000
    let dfmatter = DateFormatter()
    let date = Date(timeIntervalSince1970: timeSta)
    let zone = TimeZone(secondsFromGMT: +28800)
    dfmatter.timeZone = zone
    dfmatter.dateFormat="yyyy-MM-dd"
    //    print(dfmatter.stringFromDate(date),timeStamp)
    return dfmatter.string(from: date)
}


func DZYLog<T>(_ message: T, file: String = #file, method: String = #function, line: Int = #line) {
    
    #if DEBUG
        print("<\((file as NSString).lastPathComponent) : \(line)>, \(method)  \(message)")
    #endif
}
